package com.tiger.contact;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;


/**
 * 新增界面
 * @author tiger.chenlin
 * @date:2011-5-4 上午09:49:21
 * @file:AddContactActivity.java
 * @package:com.tiger
 */
public class AddContactActivity extends Activity {
	private EditText username,userphone;
	private Button add,reset;
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.contact_add);
		
		username=(EditText)this.findViewById(R.id.username);
		userphone=(EditText)this.findViewById(R.id.userphone);
		add=(Button)this.findViewById(R.id.add);
		reset=(Button)this.findViewById(R.id.reset);
		reset.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View arg0) {
				username.setText("");
				userphone.setText("");
			}
			
		});
		add.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				String user=username.getText().toString();
				String phone=userphone.getText().toString();
				Log.i("MMALL", "user_phone:"+user+"_"+phone);
				ContactEntity contact=new ContactEntity();
				contact.setName(user);
				contact.setPhoneNum(phone);
//				ContactUtil.getInstance().insert(AddContactActivity.this, contact);
				ContactUtil.getInstance().insertSimContact(AddContactActivity.this, contact);
				AddContactActivity.this.startActivity(new Intent(AddContactActivity.this,MainActivity.class));
			}
			
		});
	}

}